package org.jivesoftware.smack;

import com.easemob.util.EMLog;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Mode;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.Item;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import org.jivesoftware.smack.util.StringUtils;

public class Roster
{
  private static SubscriptionMode defaultSubscriptionMode = SubscriptionMode.accept_all;
  private RosterStorage persistentStorage;
  private Connection connection;
  private final Map<String, RosterGroup> groups;
  private final Map<String, RosterEntry> entries;
  private final List<RosterEntry> unfiledEntries;
  private final List<RosterListener> rosterListeners;
  private Map<String, Map<String, Presence>> presenceMap;
  boolean rosterInitialized = false;
  private PresencePacketListener presencePacketListener;
  private SubscriptionMode subscriptionMode = getDefaultSubscriptionMode();
  private String requestPacketId;

  public static SubscriptionMode getDefaultSubscriptionMode()
  {
    return defaultSubscriptionMode;
  }

  public static void setDefaultSubscriptionMode(SubscriptionMode paramSubscriptionMode)
  {
    defaultSubscriptionMode = paramSubscriptionMode;
  }

  Roster(Connection paramConnection, RosterStorage paramRosterStorage)
  {
    this(paramConnection);
    this.persistentStorage = paramRosterStorage;
    loadFromStorage();
  }

  Roster(Connection paramConnection)
  {
    this.connection = paramConnection;
    if (!paramConnection.getConfiguration().isRosterVersioningAvailable())
      this.persistentStorage = null;
    this.groups = new ConcurrentHashMap();
    this.unfiledEntries = new CopyOnWriteArrayList();
    this.entries = new ConcurrentHashMap();
    this.rosterListeners = new CopyOnWriteArrayList();
    this.presenceMap = new ConcurrentHashMap();
    PacketTypeFilter localPacketTypeFilter1 = new PacketTypeFilter(RosterPacket.class);
    paramConnection.addPacketListener(new RosterPacketListener(null), localPacketTypeFilter1);
    PacketTypeFilter localPacketTypeFilter2 = new PacketTypeFilter(Presence.class);
    this.presencePacketListener = new PresencePacketListener(null);
    paramConnection.addPacketListener(this.presencePacketListener, localPacketTypeFilter2);
    final AbstractConnectionListener local1 = new AbstractConnectionListener()
    {
      public void connectionClosed()
      {
        Roster.this.setOfflinePresences();
      }

      public void connectionClosedOnError(Exception paramAnonymousException)
      {
        Roster.this.setOfflinePresences();
      }
    };
    if (!this.connection.isConnected())
      Connection.addConnectionCreationListener(new ConnectionCreationListener()
      {
        public void connectionCreated(Connection paramAnonymousConnection)
        {
          if (paramAnonymousConnection.equals(Roster.this.connection))
            Roster.this.connection.addConnectionListener(local1);
        }
      });
    else
      paramConnection.addConnectionListener(local1);
  }

  public SubscriptionMode getSubscriptionMode()
  {
    return this.subscriptionMode;
  }

  public void setSubscriptionMode(SubscriptionMode paramSubscriptionMode)
  {
    this.subscriptionMode = paramSubscriptionMode;
  }

  public void reload()
  {
    if (!this.connection.isAuthenticated())
      throw new IllegalStateException("Not logged in to server.");
    if (this.connection.isAnonymous())
      throw new IllegalStateException("Anonymous users can't have a roster.");
    RosterPacket localRosterPacket = new RosterPacket();
    if (this.persistentStorage != null)
      localRosterPacket.setVersion(this.persistentStorage.getRosterVersion());
    this.requestPacketId = localRosterPacket.getPacketID();
    PacketIDFilter localPacketIDFilter = new PacketIDFilter(this.requestPacketId);
    this.connection.addPacketListener(new RosterResultListener(null), localPacketIDFilter);
    this.connection.sendPacket(localRosterPacket);
  }

  public void addRosterListener(RosterListener paramRosterListener)
  {
    if (!this.rosterListeners.contains(paramRosterListener))
      this.rosterListeners.add(paramRosterListener);
  }

  public void removeRosterListener(RosterListener paramRosterListener)
  {
    this.rosterListeners.remove(paramRosterListener);
  }

  public RosterGroup createGroup(String paramString)
  {
    if (!this.connection.isAuthenticated())
      throw new IllegalStateException("Not logged in to server.");
    if (this.connection.isAnonymous())
      throw new IllegalStateException("Anonymous users can't have a roster.");
    if (this.groups.containsKey(paramString))
      throw new IllegalArgumentException("Group with name " + paramString + " alread exists.");
    RosterGroup localRosterGroup = new RosterGroup(paramString, this.connection);
    this.groups.put(paramString, localRosterGroup);
    return localRosterGroup;
  }

  public void createEntry(String paramString1, String paramString2, String[] paramArrayOfString)
    throws XMPPException
  {
    if (!this.connection.isAuthenticated())
      throw new IllegalStateException("Not logged in to server.");
    if (this.connection.isAnonymous())
      throw new IllegalStateException("Anonymous users can't have a roster.");
    RosterPacket localRosterPacket = new RosterPacket();
    localRosterPacket.setType(IQ.Type.SET);
    RosterPacket.Item localItem = new RosterPacket.Item(paramString1, paramString2);
    if (paramArrayOfString != null)
      for (localObject : paramArrayOfString)
        if ((localObject != null) && (((String)localObject).trim().length() > 0))
          localItem.addGroupName((String)localObject);
    localRosterPacket.addRosterItem(localItem);
    Object localObject = this.connection.createPacketCollector(new PacketIDFilter(localRosterPacket.getPacketID()));
    this.connection.sendPacket(localRosterPacket);
    IQ localIQ = (IQ)((PacketCollector)localObject).nextResult(SmackConfiguration.getPacketReplyTimeout());
    ((PacketCollector)localObject).cancel();
    if (localIQ == null)
      throw new XMPPException("No response from the server.");
    if (localIQ.getType() == IQ.Type.ERROR)
      throw new XMPPException(localIQ.getError());
    Presence localPresence = new Presence(Presence.Type.subscribe);
    localPresence.setTo(paramString1);
    this.connection.sendPacket(localPresence);
  }

  private void insertRosterItems(List<RosterPacket.Item> paramList)
  {
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    ArrayList localArrayList3 = new ArrayList();
    Iterator localIterator = paramList.iterator();
    while (localIterator.hasNext())
      insertRosterItem((RosterPacket.Item)localIterator.next(), localArrayList1, localArrayList2, localArrayList3);
    fireRosterChangedEvent(localArrayList1, localArrayList2, localArrayList3);
  }

  private void insertRosterItem(RosterPacket.Item paramItem, Collection<String> paramCollection1, Collection<String> paramCollection2, Collection<String> paramCollection3)
  {
    RosterEntry localRosterEntry = new RosterEntry(paramItem.getUser(), paramItem.getName(), paramItem.getItemType(), paramItem.getItemStatus(), this, this.connection);
    if (RosterPacket.ItemType.remove.equals(paramItem.getItemType()))
    {
      if (this.entries.containsKey(paramItem.getUser()))
        this.entries.remove(paramItem.getUser());
      if (this.unfiledEntries.contains(localRosterEntry))
        this.unfiledEntries.remove(localRosterEntry);
      localObject1 = StringUtils.parseName(paramItem.getUser()) + "@" + StringUtils.parseServer(paramItem.getUser());
      this.presenceMap.remove(localObject1);
      if (paramCollection3 != null)
        paramCollection3.add(paramItem.getUser());
    }
    else
    {
      if (!this.entries.containsKey(paramItem.getUser()))
      {
        this.entries.put(paramItem.getUser(), localRosterEntry);
        if (paramCollection1 != null)
          paramCollection1.add(paramItem.getUser());
      }
      else
      {
        this.entries.put(paramItem.getUser(), localRosterEntry);
        if (paramCollection2 != null)
          paramCollection2.add(paramItem.getUser());
      }
      if (!paramItem.getGroupNames().isEmpty())
        this.unfiledEntries.remove(localRosterEntry);
      else if (!this.unfiledEntries.contains(localRosterEntry))
        this.unfiledEntries.add(localRosterEntry);
    }
    Object localObject1 = new ArrayList();
    Object localObject3 = getGroups().iterator();
    Object localObject2;
    while (((Iterator)localObject3).hasNext())
    {
      localObject2 = (RosterGroup)((Iterator)localObject3).next();
      if (((RosterGroup)localObject2).contains(localRosterEntry))
        ((List)localObject1).add(((RosterGroup)localObject2).getName());
    }
    Object localObject4;
    if (!RosterPacket.ItemType.remove.equals(paramItem.getItemType()))
    {
      localObject2 = new ArrayList();
      localObject4 = paramItem.getGroupNames().iterator();
      while (((Iterator)localObject4).hasNext())
      {
        localObject3 = (String)((Iterator)localObject4).next();
        ((List)localObject2).add(localObject3);
        RosterGroup localRosterGroup = getGroup((String)localObject3);
        if (localRosterGroup == null)
        {
          localRosterGroup = createGroup((String)localObject3);
          this.groups.put(localObject3, localRosterGroup);
        }
        localRosterGroup.addEntryLocal(localRosterEntry);
      }
      localObject4 = ((List)localObject2).iterator();
      while (((Iterator)localObject4).hasNext())
      {
        localObject3 = (String)((Iterator)localObject4).next();
        ((List)localObject1).remove(localObject3);
      }
    }
    localObject3 = ((List)localObject1).iterator();
    while (((Iterator)localObject3).hasNext())
    {
      localObject2 = (String)((Iterator)localObject3).next();
      localObject4 = getGroup((String)localObject2);
      ((RosterGroup)localObject4).removeEntryLocal(localRosterEntry);
      if (((RosterGroup)localObject4).getEntryCount() == 0)
        this.groups.remove(localObject2);
    }
    localObject3 = getGroups().iterator();
    while (((Iterator)localObject3).hasNext())
    {
      localObject2 = (RosterGroup)((Iterator)localObject3).next();
      if (((RosterGroup)localObject2).getEntryCount() == 0)
        this.groups.remove(((RosterGroup)localObject2).getName());
    }
  }

  public void removeEntry(RosterEntry paramRosterEntry)
    throws XMPPException
  {
    if (!this.connection.isAuthenticated())
      throw new IllegalStateException("Not logged in to server.");
    if (this.connection.isAnonymous())
      throw new IllegalStateException("Anonymous users can't have a roster.");
    if (!this.entries.containsKey(paramRosterEntry.getUser()))
      return;
    RosterPacket localRosterPacket = new RosterPacket();
    localRosterPacket.setType(IQ.Type.SET);
    RosterPacket.Item localItem = RosterEntry.toRosterItem(paramRosterEntry);
    localItem.setItemType(RosterPacket.ItemType.remove);
    localRosterPacket.addRosterItem(localItem);
    PacketCollector localPacketCollector = this.connection.createPacketCollector(new PacketIDFilter(localRosterPacket.getPacketID()));
    this.connection.sendPacket(localRosterPacket);
    IQ localIQ = (IQ)localPacketCollector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    localPacketCollector.cancel();
    if (localIQ == null)
      throw new XMPPException("No response from the server.");
    if (localIQ.getType() == IQ.Type.ERROR)
      throw new XMPPException(localIQ.getError());
  }

  public int getEntryCount()
  {
    return getEntries().size();
  }

  public Collection<RosterEntry> getEntries()
  {
    HashSet localHashSet = new HashSet();
    Iterator localIterator = getGroups().iterator();
    while (localIterator.hasNext())
    {
      RosterGroup localRosterGroup = (RosterGroup)localIterator.next();
      localHashSet.addAll(localRosterGroup.getEntries());
    }
    localHashSet.addAll(this.unfiledEntries);
    return Collections.unmodifiableCollection(localHashSet);
  }

  public int getUnfiledEntryCount()
  {
    return this.unfiledEntries.size();
  }

  public Collection<RosterEntry> getUnfiledEntries()
  {
    return Collections.unmodifiableList(this.unfiledEntries);
  }

  public RosterEntry getEntry(String paramString)
  {
    if (paramString == null)
      return null;
    return (RosterEntry)this.entries.get(paramString.toLowerCase());
  }

  public boolean contains(String paramString)
  {
    return getEntry(paramString) != null;
  }

  public RosterGroup getGroup(String paramString)
  {
    return (RosterGroup)this.groups.get(paramString);
  }

  public int getGroupCount()
  {
    return this.groups.size();
  }

  public Collection<RosterGroup> getGroups()
  {
    return Collections.unmodifiableCollection(this.groups.values());
  }

  public Presence getPresence(String paramString)
  {
    String str1 = getPresenceMapKey(StringUtils.parseBareAddress(paramString));
    Map localMap = (Map)this.presenceMap.get(str1);
    if (localMap == null)
    {
      localObject = new Presence(Presence.Type.unavailable);
      ((Presence)localObject).setFrom(paramString);
      return localObject;
    }
    Object localObject = null;
    Iterator localIterator = localMap.keySet().iterator();
    while (localIterator.hasNext())
    {
      String str2 = (String)localIterator.next();
      Presence localPresence = (Presence)localMap.get(str2);
      if (localPresence.isAvailable())
        if ((localObject == null) || (localPresence.getPriority() > ((Presence)localObject).getPriority()))
        {
          localObject = localPresence;
        }
        else if (localPresence.getPriority() == ((Presence)localObject).getPriority())
        {
          Presence.Mode localMode1 = localPresence.getMode();
          if (localMode1 == null)
            localMode1 = Presence.Mode.available;
          Presence.Mode localMode2 = ((Presence)localObject).getMode();
          if (localMode2 == null)
            localMode2 = Presence.Mode.available;
          if (localMode1.compareTo(localMode2) < 0)
            localObject = localPresence;
        }
    }
    if (localObject == null)
    {
      localObject = new Presence(Presence.Type.unavailable);
      ((Presence)localObject).setFrom(paramString);
      return localObject;
    }
    return localObject;
  }

  public Presence getPresenceResource(String paramString)
  {
    String str1 = getPresenceMapKey(paramString);
    String str2 = StringUtils.parseResource(paramString);
    Map localMap = (Map)this.presenceMap.get(str1);
    if (localMap == null)
    {
      localPresence = new Presence(Presence.Type.unavailable);
      localPresence.setFrom(paramString);
      return localPresence;
    }
    Presence localPresence = (Presence)localMap.get(str2);
    if (localPresence == null)
    {
      localPresence = new Presence(Presence.Type.unavailable);
      localPresence.setFrom(paramString);
      return localPresence;
    }
    return localPresence;
  }

  public Iterator<Presence> getPresences(String paramString)
  {
    String str = getPresenceMapKey(paramString);
    Map localMap = (Map)this.presenceMap.get(str);
    if (localMap == null)
    {
      localObject = new Presence(Presence.Type.unavailable);
      ((Presence)localObject).setFrom(paramString);
      return Arrays.asList(new Presence[] { localObject }).iterator();
    }
    Object localObject = new ArrayList();
    Iterator localIterator = localMap.values().iterator();
    while (localIterator.hasNext())
    {
      localPresence = (Presence)localIterator.next();
      if (localPresence.isAvailable())
        ((Collection)localObject).add(localPresence);
    }
    if (!((Collection)localObject).isEmpty())
      return ((Collection)localObject).iterator();
    Presence localPresence = new Presence(Presence.Type.unavailable);
    localPresence.setFrom(paramString);
    return Arrays.asList(new Presence[] { localPresence }).iterator();
  }

  private String getPresenceMapKey(String paramString)
  {
    if (paramString == null)
      return null;
    String str = paramString;
    if (!contains(paramString))
      str = StringUtils.parseBareAddress(paramString);
    return str.toLowerCase();
  }

  private void setOfflinePresences()
  {
    Iterator localIterator1 = this.presenceMap.keySet().iterator();
    while (localIterator1.hasNext())
    {
      String str1 = (String)localIterator1.next();
      Map localMap = (Map)this.presenceMap.get(str1);
      if (localMap != null)
      {
        Iterator localIterator2 = localMap.keySet().iterator();
        while (localIterator2.hasNext())
        {
          String str2 = (String)localIterator2.next();
          Presence localPresence = new Presence(Presence.Type.unavailable);
          localPresence.setFrom(str1 + "/" + str2);
          this.presencePacketListener.processPacket(localPresence);
        }
      }
    }
  }

  private void fireRosterChangedEvent(Collection<String> paramCollection1, Collection<String> paramCollection2, Collection<String> paramCollection3)
  {
    Iterator localIterator = this.rosterListeners.iterator();
    while (localIterator.hasNext())
    {
      RosterListener localRosterListener = (RosterListener)localIterator.next();
      if (!paramCollection1.isEmpty())
        localRosterListener.entriesAdded(paramCollection1);
      if (!paramCollection2.isEmpty())
        localRosterListener.entriesUpdated(paramCollection2);
      if (!paramCollection3.isEmpty())
        localRosterListener.entriesDeleted(paramCollection3);
    }
  }

  private void fireRosterPresenceEvent(Presence paramPresence)
  {
    Iterator localIterator = this.rosterListeners.iterator();
    while (localIterator.hasNext())
    {
      RosterListener localRosterListener = (RosterListener)localIterator.next();
      localRosterListener.presenceChanged(paramPresence);
    }
  }

  public void loadFromStorage()
  {
    if (this.persistentStorage != null)
    {
      ArrayList localArrayList1 = new ArrayList();
      ArrayList localArrayList2 = new ArrayList();
      ArrayList localArrayList3 = new ArrayList();
      Iterator localIterator = this.persistentStorage.getEntries().iterator();
      while (localIterator.hasNext())
      {
        RosterPacket.Item localItem = (RosterPacket.Item)localIterator.next();
        insertRosterItem(localItem, localArrayList1, localArrayList2, localArrayList3);
      }
    }
  }

  private class PresencePacketListener
    implements PacketListener
  {
    private PresencePacketListener()
    {
    }

    public void processPacket(Packet paramPacket)
    {
      Presence localPresence = (Presence)paramPacket;
      String str1 = localPresence.getFrom();
      String str2 = Roster.this.getPresenceMapKey(str1);
      Object localObject;
      RosterEntry localRosterEntry;
      if (localPresence.getType() == Presence.Type.available)
      {
        if (Roster.this.presenceMap.get(str2) == null)
        {
          localObject = new ConcurrentHashMap();
          Roster.this.presenceMap.put(str2, localObject);
        }
        else
        {
          localObject = (Map)Roster.this.presenceMap.get(str2);
        }
        ((Map)localObject).remove("");
        ((Map)localObject).put(StringUtils.parseResource(str1), localPresence);
        localRosterEntry = (RosterEntry)Roster.this.entries.get(str2);
        if (localRosterEntry != null)
          Roster.this.fireRosterPresenceEvent(localPresence);
      }
      else if (localPresence.getType() == Presence.Type.unavailable)
      {
        if ("".equals(StringUtils.parseResource(str1)))
        {
          if (Roster.this.presenceMap.get(str2) == null)
          {
            localObject = new ConcurrentHashMap();
            Roster.this.presenceMap.put(str2, localObject);
          }
          else
          {
            localObject = (Map)Roster.this.presenceMap.get(str2);
          }
          ((Map)localObject).put("", localPresence);
        }
        else if (Roster.this.presenceMap.get(str2) != null)
        {
          localObject = (Map)Roster.this.presenceMap.get(str2);
          ((Map)localObject).put(StringUtils.parseResource(str1), localPresence);
        }
        localObject = (RosterEntry)Roster.this.entries.get(str2);
        if (localObject != null)
          Roster.this.fireRosterPresenceEvent(localPresence);
      }
      else if (localPresence.getType() == Presence.Type.subscribe)
      {
        if (Roster.this.subscriptionMode == Roster.SubscriptionMode.accept_all)
        {
          localObject = new Presence(Presence.Type.subscribed);
          ((Presence)localObject).setTo(localPresence.getFrom());
          Roster.this.connection.sendPacket((Packet)localObject);
        }
        else if (Roster.this.subscriptionMode == Roster.SubscriptionMode.reject_all)
        {
          localObject = new Presence(Presence.Type.unsubscribed);
          ((Presence)localObject).setTo(localPresence.getFrom());
          Roster.this.connection.sendPacket((Packet)localObject);
        }
      }
      else if (localPresence.getType() == Presence.Type.unsubscribe)
      {
        if (Roster.this.subscriptionMode != Roster.SubscriptionMode.manual)
        {
          localObject = new Presence(Presence.Type.unsubscribed);
          ((Presence)localObject).setTo(localPresence.getFrom());
          Roster.this.connection.sendPacket((Packet)localObject);
        }
      }
      else if ((localPresence.getType() == Presence.Type.error) && ("".equals(StringUtils.parseResource(str1))))
      {
        if (!Roster.this.presenceMap.containsKey(str2))
        {
          localObject = new ConcurrentHashMap();
          Roster.this.presenceMap.put(str2, localObject);
        }
        else
        {
          localObject = (Map)Roster.this.presenceMap.get(str2);
          ((Map)localObject).clear();
        }
        ((Map)localObject).put("", localPresence);
        localRosterEntry = (RosterEntry)Roster.this.entries.get(str2);
        if (localRosterEntry != null)
          Roster.this.fireRosterPresenceEvent(localPresence);
      }
    }
  }

  private class RosterPacketListener
    implements PacketListener
  {
    private RosterPacketListener()
    {
    }

    public void processPacket(Packet paramPacket)
    {
      ArrayList localArrayList1 = new ArrayList();
      ArrayList localArrayList2 = new ArrayList();
      ArrayList localArrayList3 = new ArrayList();
      String str = null;
      RosterPacket localRosterPacket = (RosterPacket)paramPacket;
      ArrayList localArrayList4 = new ArrayList();
      Object localObject2 = localRosterPacket.getRosterItems().iterator();
      Object localObject1;
      while (((Iterator)localObject2).hasNext())
      {
        localObject1 = (RosterPacket.Item)((Iterator)localObject2).next();
        localArrayList4.add(localObject1);
      }
      if (localRosterPacket.getVersion() == null)
        Roster.this.persistentStorage = null;
      else
        str = localRosterPacket.getVersion();
      localObject2 = localArrayList4.iterator();
      while (((Iterator)localObject2).hasNext())
      {
        localObject1 = (RosterPacket.Item)((Iterator)localObject2).next();
        Roster.this.insertRosterItem((RosterPacket.Item)localObject1, localArrayList1, localArrayList2, localArrayList3);
      }
      Object localObject3;
      if (localRosterPacket.getType() == IQ.Type.RESULT)
      {
        localObject1 = new HashSet();
        localObject3 = localArrayList4.iterator();
        while (((Iterator)localObject3).hasNext())
        {
          localObject2 = (RosterPacket.Item)((Iterator)localObject3).next();
          if (((RosterPacket.Item)localObject2).getItemType() == RosterPacket.ItemType.both)
            ((Set)localObject1).add(((RosterPacket.Item)localObject2).getUser());
        }
        localObject3 = Roster.this.entries.keySet().iterator();
        while (((Iterator)localObject3).hasNext())
        {
          localObject2 = (String)((Iterator)localObject3).next();
          if (!((Set)localObject1).contains(localObject2))
            localArrayList3.add(localObject2);
        }
      }
      if (Roster.this.persistentStorage != null)
      {
        localObject2 = localRosterPacket.getRosterItems().iterator();
        while (((Iterator)localObject2).hasNext())
        {
          localObject1 = (RosterPacket.Item)((Iterator)localObject2).next();
          if (((RosterPacket.Item)localObject1).getItemType().equals(RosterPacket.ItemType.remove))
            Roster.this.persistentStorage.removeEntry(((RosterPacket.Item)localObject1).getUser(), str);
          else
            Roster.this.persistentStorage.addEntry((RosterPacket.Item)localObject1, str);
        }
        if ((localRosterPacket.getType() == IQ.Type.RESULT) && (localArrayList3.size() > 0))
        {
          localObject2 = localArrayList3.iterator();
          while (((Iterator)localObject2).hasNext())
          {
            localObject1 = (String)((Iterator)localObject2).next();
            if (Roster.this.entries.containsKey(localObject1))
            {
              localObject3 = (RosterEntry)Roster.this.entries.get(localObject1);
              Roster.this.entries.remove(localObject1);
              Roster.this.unfiledEntries.remove(localObject3);
            }
            Roster.this.persistentStorage.removeEntry((String)localObject1, str);
            EMLog.d("Roster", "roster remove:" + (String)localObject1);
          }
        }
      }
      synchronized (Roster.this)
      {
        Roster.this.rosterInitialized = true;
        EMLog.d("roster", "rosterInitialized set to true 1");
        Roster.this.notifyAll();
      }
      Roster.this.fireRosterChangedEvent(localArrayList1, localArrayList2, localArrayList3);
    }
  }

  private class RosterResultListener
    implements PacketListener
  {
    private RosterResultListener()
    {
    }

    public void processPacket(Packet paramPacket)
    {
      if (((paramPacket instanceof IQ)) && (!(paramPacket instanceof RosterPacket)))
      {
        IQ localIQ = (IQ)paramPacket;
        if ((localIQ.getType().equals(IQ.Type.RESULT)) && (localIQ.getExtensions().isEmpty()))
          synchronized (Roster.this)
          {
            Roster.this.rosterInitialized = true;
            EMLog.d("roster", "rosterInitialized set to true 2");
            Roster.this.notifyAll();
          }
      }
      Roster.this.connection.removePacketListener(this);
    }
  }

  public static enum SubscriptionMode
  {
    accept_all, reject_all, manual;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.Roster
 * JD-Core Version:    0.6.1
 */